package com.TTBook.impl.system.daoImpl;

import java.util.List;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.TTBook.core.system.dao.SysParamsDAO;
import com.TTBook.core.system.model.SysParams;
import com.TTBook.core.system.model.SysParamsCriteria;

public class SysParamsDAOImpl extends SqlMapClientDaoSupport implements
		SysParamsDAO {

	public SysParamsDAOImpl() {
		super();
	}

	public int countByCriteria(SysParamsCriteria criteria) {
		Integer count = (Integer) getSqlMapClientTemplate().queryForObject(
				"sys_params.countByCriteria", criteria);
		return count.intValue();
	}

	public int deleteByCriteria(SysParamsCriteria criteria) {
		int rows = getSqlMapClientTemplate().delete(
				"sys_params.deleteByCriteria", criteria);
		return rows;
	}

	public int deleteByPrimaryKey(String innerName) {
		SysParams key = new SysParams();
		key.setInnerName(innerName);
		int rows = getSqlMapClientTemplate().delete(
				"sys_params.deleteByPrimaryKey", key);
		return rows;
	}

	public void insert(SysParams record) {
		getSqlMapClientTemplate().insert("sys_params.insert", record);
	}

	public void insertSelective(SysParams record) {
		getSqlMapClientTemplate().insert("sys_params.insertSelective", record);
	}

	public List selectByCriteria(SysParamsCriteria criteria) {
		List list = getSqlMapClientTemplate().queryForList(
				"sys_params.selectByCriteria", criteria);
		return list;
	}

	public SysParams selectByPrimaryKey(String innerName) {
		SysParams key = new SysParams();
		key.setInnerName(innerName);
		SysParams record = (SysParams) getSqlMapClientTemplate()
				.queryForObject("sys_params.selectByPrimaryKey", key);
		return record;
	}

	public int updateByCriteriaSelective(SysParams record,
			SysParamsCriteria criteria) {
		UpdateByCriteriaParms parms = new UpdateByCriteriaParms(record,
				criteria);
		int rows = getSqlMapClientTemplate().update(
				"sys_params.updateByCriteriaSelective", parms);
		return rows;
	}

	public int updateByCriteria(SysParams record, SysParamsCriteria example) {
		UpdateByCriteriaParms parms = new UpdateByCriteriaParms(record, example);
		int rows = getSqlMapClientTemplate().update(
				"sys_params.updateByCriteria", parms);
		return rows;
	}

	public int updateByPrimaryKeySelective(SysParams record) {
		int rows = getSqlMapClientTemplate().update(
				"sys_params.updateByPrimaryKeySelective", record);
		return rows;
	}

	public int updateByPrimaryKey(SysParams record) {
		int rows = getSqlMapClientTemplate().update(
				"sys_params.updateByPrimaryKey", record);
		return rows;
	}

	private static class UpdateByCriteriaParms extends SysParamsCriteria {
		private Object record;

		public UpdateByCriteriaParms(Object record, SysParamsCriteria criteria) {
			super(criteria);
			this.record = record;
		}

		public Object getRecord() {
			return record;
		}
	}

	@Override
	public int countByParams(SysParams sysParams) {
		return ((Integer) getSqlMapClientTemplate().queryForObject(
				"sys_params.countByParams", sysParams)).intValue();
	}

	@Override
	public List<SysParams> selectByParams(SysParams sysParams) {
		List<SysParams> list = getSqlMapClientTemplate().queryForList("sys_params.selectByParams",sysParams);
		return list;
	}
	
}